package com.yfyszk.kingbird.controller;

import com.yfyszk.kingbird.annotation.Log;
import com.yfyszk.kingbird.common.redis.RedisUtils;
import com.yfyszk.kingbird.common.utils.R;
import com.yfyszk.kingbird.feign.OrderFeignClient;
import com.yfyszk.kingbird.feign.UserFeignClient;
import com.yfyszk.kingbird.service.IMemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/testUser")
@CrossOrigin
public class UserTestController  implements UserFeignClient{
    @Autowired
    private  RedisUtils redisUtils;
    @Autowired
    private UserFeignClient userFeignClient;
    @Autowired
    private IMemberService memberService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Log(action = "addDataDicOrUpdate", modelName = "新增或修改数据字典", description = "新增或修改数据字典",platform="1",status="1")
    @Override
    public String getUser(@RequestParam("name") String name) {
        redisUtils.set("name",name);
        log.info("name:{}",name);
        return "OK1111"+name;
    }

    @Override
    public String getUserOrder(@RequestParam("orderId") String orderId) {
        String order = memberService.getUserOrder(orderId);
        System.out.println(order);
        return  order;
    }
    //根据订单id查询用户信息
    @Override
    public R  getUserByOrderId(String orderId) {
        log.info("orderId:{}",orderId);
        String data="该订单号["+orderId+"]是张三的";
        return R.ok().setData(data);
    }


}
